package reflect;

import java.lang.reflect.Field;
import java.util.Arrays;

/**
 * 暴力反射
 */
public class ReflectDemo9 {
    public static void main(String[] args) throws Exception {
        String s1="hello";
        String s2="hello";
        String s3="hello";
        System.out.println("s1"+s1);
        System.out.println("s2"+s2);
        System.out.println("s3"+s3);
        System.out.println("s1==s2"+(s1==s2));
        System.out.println("s1==s3"+(s1==s3));
        Class cls=String.class;
        Field field=cls.getDeclaredField("value");
        field.setAccessible(true);
        char[]value=(char[])field.get(s1);
        System.out.println(Arrays.toString( value));
        field.set(s1,new char[]{'w','o','r','l','d'});

        System.out.println("s1"+s1);
        System.out.println("s2"+s2);
        System.out.println("s3"+s3);

        String s4="hello";
        System.out.println("s4"+s4);


    }
}
